package ro.licenta.main;

import ro.licenta.utilities.utils.PreferencesUtils;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;

import com.example.test.R;

public class LoadingActivity extends Activity {

	private Button startGame, helpGame;
	private PreferencesUtils mPrefs;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		mPrefs = new PreferencesUtils(this);
		if (!mPrefs.getGameStarted()) {
			this.requestWindowFeature(Window.FEATURE_NO_TITLE);
			setContentView(R.layout.loading);
			startGame = (Button) findViewById(R.id.playButton);
			helpGame = (Button) findViewById(R.id.helpButton);
			startGame.setOnClickListener(myClickListener);
			helpGame.setOnClickListener(myClickListener);
		} else {
			Intent intent = new Intent(this, MainActivity.class);
			startActivity(intent);
			finish();
		}

	}

	private OnClickListener myClickListener = new OnClickListener() {
		public void onClick(View v) {
			switch (v.getId()) {
			case R.id.playButton: {
				finish();
				Intent intent1 = new Intent(LoadingActivity.this,
						SettingsActivity.class);
				startActivity(intent1);
				break;
			}
			case R.id.helpButton: {
				finish();
				Intent intent2 = new Intent(LoadingActivity.this,
						HelpActivity.class);
				startActivity(intent2);
				break;
			}
			}

		}
	};

	public boolean onCreateOptionsMenu(Menu menu) {
		MenuInflater inflater = getMenuInflater();
		inflater.inflate(R.menu.loading, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case R.id.settings: {
			return true;
		}
		default:
			return super.onOptionsItemSelected(item);
		}
	}

}
